﻿package Players
{	
	import Events.XMLEvent;
	import Utils.*;
	import Items.Item;
	import Graphics.Animation;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Point;
	
	public class Player extends GameSprite
	{
		protected var items:Array = new Array();
		protected var currentItem:Item;
		public function get CurrentItem():Item { return currentItem;}
		
		public override function set Level(value:Level):void 
		{
			this.level = value;
			var index:int;
			for(index = 0; index < items.length; index++)
			{
				items[index].Level = this.level;
			}
		}
		
		public function Player(game:Level)
		{
			super(game);
		}
		
		public function Reset():void
		{
			isDead = false;
			currentHealth = maxHealth;
		}
		
		public override function Update(deltaTime:int):void
		{
			super.Update(deltaTime);
			HandleInput();
			if(isDead)
			{
				this.level.GameLevel.LostGame();
			}
		}
		
		private function HandleInput():void
		{
			
		}
		
		public override function Draw(camera:Camera,canvas:BitmapData):BitmapData
		{
			if(currentAnimation != null)
			{
				if(currentAnimation.Graphic != null)
				{
					canvas.copyPixels(currentAnimation.Graphic.bitmapData, blitRectangle, position);
				}
			}
			return canvas;
		}
		
		public function UseItem(item:Item):void
		{
			item.Activate();
		}

		
		public function EquipItem(item:Item):void
		{
			currentItem = item;
		}
	}
}